package com.ruoyi.fangyuan.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.fangyuan.domain.TbRoomReservation;
import com.ruoyi.fangyuan.service.ITbRoomReservationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 预约房源Controller
 * 
 * @author ruoyi
 * @date 2023-04-23
 */
@RestController
@RequestMapping("/reservation")
public class TbRoomReservationController extends BaseController
{
    @Autowired
    private ITbRoomReservationService tbRoomReservationService;

    /**
     * 查询预约房源列表
     */
//    @RequiresPermissions("fangyuan:reservation:list")
    @GetMapping("/list")
    public TableDataInfo list(TbRoomReservation tbRoomReservation)
    {
        startPage();
        List<TbRoomReservation> list = tbRoomReservationService.selectTbRoomReservationList(tbRoomReservation);
        return getDataTable(list);
    }


    /**
     * 获取预约房源详细信息
     */
//    @RequiresPermissions("fangyuan:reservation:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbRoomReservationService.selectTbRoomReservationById(id));
    }

    /**
     * 新增预约房源
     */
//    @RequiresPermissions("fangyuan:reservation:add")
    @Log(title = "预约房源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRoomReservation tbRoomReservation)
    {
        return toAjax(tbRoomReservationService.insertTbRoomReservation(tbRoomReservation));
    }

    /**
     * 修改预约房源
     */
//    @RequiresPermissions("fangyuan:reservation:edit")
    @Log(title = "预约房源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbRoomReservation tbRoomReservation)
    {
        System.out.println(tbRoomReservation);
        return toAjax(tbRoomReservationService.updateTbRoomReservation(tbRoomReservation));
    }


    /**
     * 删除预约房源
     */
//    @RequiresPermissions("fangyuan:reservation:remove")
    @Log(title = "预约房源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbRoomReservationService.deleteTbRoomReservationByIds(ids));
    }
}
